package cn.itsource.org.mapper;

import cn.itsource.org.domain.Employee;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

public interface EmployeeMapper extends Mapper<Employee> {

    //1.写在default
   /* default Employee selectInfo(String username){

        Example example = new Example(Employee.class);
        example.or().orEqualTo("username",username)
                .orEqualTo("email",username)
                .orEqualTo("phone",username);

        return this.selectOneByExample(example);
    }*/

    //2.直接加注解
    @Select("select * from t_employee where username = #{username} or email = #{username} or phone = #{username}")
    Employee selectInfo(String username);


    default List<Employee> employeeMapper(Long shopId){
        //封装条件,根据店铺id查询店铺所有的员工
        Example example = new Example(Employee.class);
        example.and().andEqualTo("shopId",shopId);
        //返回
        return this.selectByExample(example);


    }


    //3.xml里面写语句
}
